<?php
$con = mysql_connect("localhost","cubeMass_f","cubeSelectNow");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("cubeMass", $con);
session_start();
	
	if(!session_is_registered('model_'.$_POST['model_id'])){
		$sql = "SELECT * FROM model WHERE ID = '$_POST[model_id]'";
		$result_model = mysql_query($sql,$con);
		$row_model = mysql_fetch_array($result_model);
		
		echo "ok?";
		$viewTimes = $row_model['visitedTimes']+1;
		$sql = "UPDATE model SET visitedTimes = '$viewTimes' WHERE ID = '$_POST[model_id]'";
		mysql_query($sql,$con);
		
		$_SESSION['model_'.$_POST['model_id']] = true;
		}
	
mysql_close($con);
?>
